.align 2
.section .data
tape:
	.zero	262144
program:
	.zero	131072
ptr:
	.word	0
.section .text
.global __aeabi_memclr4
__aeabi_memclr4:
.L1:
		MV	t5, a0
		MV	t6, a1
		ADD	t6, a0, t6
		LI	a0, 0
.L2:
		SW	zero, (t5)
		ADDI	t5, t5, 4
		BLT	t5, t6, .L2
		RET
.global read_program
read_program:
.L3:
		ADDI	sp, sp, -160
		SD	fp, 32(sp)
		ADDI	fp, sp, 160
		SD	ra, -136(fp)
		SD	s2, -144(fp)
		SD	s3, -152(fp)
		SD	s4, -160(fp)
.L4:
		LI	t0, 0
		SW	t0, -120(fp)
		ADDI	sp, sp, -8
		CALL	getint
		ADDI	sp, sp, 8
		SW	a0, -16(fp)
		LW	s2, -16(fp)
		SW	s2, -112(fp)
		SW	s2, -16(fp)
		J	.L5
.L6:
		LD	s4, -160(fp)
		LD	s3, -152(fp)
		LD	s2, -144(fp)
		LD	ra, -136(fp)
		LD	fp, -128(fp)
		ADDI	sp, sp, 160
		RET
.L5:
		LW	s2, -120(fp)
		LW	s3, -112(fp)
		SLT	s4, s2, s3
		SW	s2, -32(fp)
		SW	s3, -40(fp)
		SW	s4, -48(fp)
		LW	s2, -48(fp)
		BGTZ	s2, .L7
		J	.L8
.L7:
		LW	s3, -120(fp)
		LA	t2, program
		LI	t3, 4
		MUL	t3, s3, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -64(fp)
		ADDI	sp, sp, -8
		CALL	getch
		ADDI	sp, sp, 8
		SW	a0, -72(fp)
		LW	s4, -72(fp)
		LD	t4, -64(fp)
		SW	s4, (t4)
		SW	s2, -48(fp)
		LW	s2, -120(fp)
		SW	s3, -56(fp)
		LI	s3, 1
		SW	s4, -72(fp)
		ADDW	s4, s2, s3
		SW	s4, -120(fp)
		SW	s2, -80(fp)
		SW	s4, -88(fp)
		J	.L5
.L8:
		LW	s2, -120(fp)
		LA	t2, program
		LI	t3, 4
		MUL	t3, s2, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -104(fp)
		LD	t4, -104(fp)
		LI	t0, 0
		SW	t0, (t4)
		SW	s2, -96(fp)
		J	.L6
.global interpret
interpret:
.L9:
		ADDI	sp, sp, -640
		SD	fp, 32(sp)
		ADDI	fp, sp, 640
		SD	ra, -616(fp)
		SD	s2, -624(fp)
		SD	s3, -632(fp)
		SD	s4, -640(fp)
.L10:
		SD	a0, -600(fp)
		LI	t0, 0
		SW	t0, -576(fp)
		SD	a0, (fp)
		J	.L11
.L12:
		LD	s4, -640(fp)
		LD	s3, -632(fp)
		LD	s2, -624(fp)
		LD	ra, -616(fp)
		LD	fp, -608(fp)
		ADDI	sp, sp, 640
		RET
.L11:
		LW	s2, -576(fp)
		LD	s3, -600(fp)
		MV	t2, s3
		LI	t3, 4
		MUL	t3, s2, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -40(fp)
		LD	t4, -40(fp)
		LW	s4, (t4)
		SD	s3, -32(fp)
		LI	s3, 0
		SW	s2, -24(fp)
		SUB	t6, s4, s3
		SNEZ	s2, t6
		SW	s2, -56(fp)
		SW	s4, -48(fp)
		LW	s2, -56(fp)
		BGTZ	s2, .L13
		J	.L14
.L13:
		LW	s3, -576(fp)
		LD	s4, -600(fp)
		MV	t2, s4
		LI	t3, 4
		MUL	t3, s3, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -80(fp)
		SW	s2, -56(fp)
		LD	t4, -80(fp)
		LW	s2, (t4)
		SW	s2, -592(fp)
		SD	s4, -72(fp)
		LW	s4, -592(fp)
		SW	s3, -64(fp)
		LI	s3, 62
		SW	s2, -88(fp)
		SUB	t6, s4, s3
		SEQZ	s2, t6
		SW	s2, -112(fp)
		SW	s4, -104(fp)
		LW	s2, -112(fp)
		BGTZ	s2, .L15
		J	.L16
.L14:
		SW	s2, -112(fp)
		J	.L12
.L15:
		LA	t5, ptr
		LW	s2, (t5)
		LI	s3, 1
		ADDW	s4, s2, s3
		LA	t5, ptr
		SW	s4, (t5)
		SW	s2, -120(fp)
		SW	s4, -128(fp)
		J	.L17
.L16:
		LW	s2, -592(fp)
		LI	s3, 60
		SUB	t6, s2, s3
		SEQZ	s4, t6
		SW	s2, -136(fp)
		SW	s4, -144(fp)
		LW	s2, -144(fp)
		BGTZ	s2, .L18
		J	.L19
.L17:
		LW	s3, -576(fp)
		LI	s4, 1
		SW	s2, -144(fp)
		ADDW	s2, s3, s4
		SW	s2, -576(fp)
		SW	s2, -160(fp)
		SW	s3, -152(fp)
		J	.L11
.L18:
		LA	t5, ptr
		LW	s2, (t5)
		LI	s3, 1
		SUB	s4, s2, s3
		LA	t5, ptr
		SW	s4, (t5)
		SW	s2, -168(fp)
		SW	s4, -176(fp)
		J	.L20
.L19:
		LW	s2, -592(fp)
		LI	s3, 43
		SUB	t6, s2, s3
		SEQZ	s4, t6
		SW	s2, -184(fp)
		SW	s4, -192(fp)
		LW	s2, -192(fp)
		BGTZ	s2, .L21
		J	.L22
.L20:
		SW	s2, -192(fp)
		J	.L17
.L21:
		LA	t5, ptr
		LW	s2, (t5)
		LA	t2, tape
		LI	t3, 4
		MUL	t3, s2, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -208(fp)
		LA	t5, ptr
		LW	s3, (t5)
		LA	t2, tape
		LI	t3, 4
		MUL	t3, s3, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -224(fp)
		LD	t4, -224(fp)
		LW	s4, (t4)
		SW	s2, -200(fp)
		LI	s2, 1
		SW	s3, -216(fp)
		ADDW	s3, s4, s2
		LD	t4, -208(fp)
		SW	s3, (t4)
		SW	s3, -240(fp)
		SW	s4, -232(fp)
		J	.L23
.L22:
		LW	s2, -592(fp)
		LI	s3, 45
		SUB	t6, s2, s3
		SEQZ	s4, t6
		SW	s2, -248(fp)
		SW	s4, -256(fp)
		LW	s2, -256(fp)
		BGTZ	s2, .L24
		J	.L25
.L23:
		SW	s2, -256(fp)
		J	.L20
.L24:
		LA	t5, ptr
		LW	s2, (t5)
		LA	t2, tape
		LI	t3, 4
		MUL	t3, s2, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -272(fp)
		LA	t5, ptr
		LW	s3, (t5)
		LA	t2, tape
		LI	t3, 4
		MUL	t3, s3, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -288(fp)
		LD	t4, -288(fp)
		LW	s4, (t4)
		SW	s2, -264(fp)
		LI	s2, 1
		SW	s3, -280(fp)
		SUB	s3, s4, s2
		LD	t4, -272(fp)
		SW	s3, (t4)
		SW	s3, -304(fp)
		SW	s4, -296(fp)
		J	.L26
.L25:
		LW	s2, -592(fp)
		LI	s3, 46
		SUB	t6, s2, s3
		SEQZ	s4, t6
		SW	s2, -312(fp)
		SW	s4, -320(fp)
		LW	s2, -320(fp)
		BGTZ	s2, .L27
		J	.L28
.L26:
		SW	s2, -320(fp)
		J	.L23
.L27:
		LA	t5, ptr
		LW	s2, (t5)
		LA	t2, tape
		LI	t3, 4
		MUL	t3, s2, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -336(fp)
		LD	t4, -336(fp)
		LW	s3, (t4)
		ADDI	sp, sp, -24
		SW	s3, -344(fp)
		LW	a0, -344(fp)
		CALL	putch
		ADDI	sp, sp, 24
		SW	s2, -328(fp)
		SW	a0, -344(fp)
		J	.L29
.L28:
		LW	s2, -592(fp)
		LI	s3, 44
		SUB	t6, s2, s3
		SEQZ	s4, t6
		SW	s2, -352(fp)
		SW	s4, -360(fp)
		LW	s2, -360(fp)
		BGTZ	s2, .L30
		J	.L31
.L29:
		SW	s2, -360(fp)
		J	.L26
.L30:
		LA	t5, ptr
		LW	s2, (t5)
		LA	t2, tape
		LI	t3, 4
		MUL	t3, s2, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -376(fp)
		ADDI	sp, sp, -8
		CALL	getch
		ADDI	sp, sp, 8
		SW	a0, -384(fp)
		LW	s3, -384(fp)
		LD	t4, -376(fp)
		SW	s3, (t4)
		SW	s2, -368(fp)
		SW	s3, -384(fp)
		J	.L32
.L31:
		LW	s2, -592(fp)
		LI	s3, 93
		SUB	t6, s2, s3
		SEQZ	s4, t6
		SW	s2, -392(fp)
		SW	s4, -400(fp)
		LW	s2, -400(fp)
		BGTZ	s2, .L33
		J	.L34
.L32:
		SW	s2, -400(fp)
		J	.L29
.L35:
		LI	t0, 1
		SW	t0, -584(fp)
		J	.L36
.L34:
		J	.L32
.L33:
		LA	t5, ptr
		LW	s2, (t5)
		LA	t2, tape
		LI	t3, 4
		MUL	t3, s2, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -424(fp)
		LD	t4, -424(fp)
		LW	s3, (t4)
		LI	s4, 0
		SW	s2, -416(fp)
		SUB	t6, s3, s4
		SNEZ	s2, t6
		SW	s2, -440(fp)
		SW	s3, -432(fp)
		LW	s2, -440(fp)
		BGTZ	s2, .L35
		J	.L34
.L36:
		LW	s3, -584(fp)
		LI	s4, 0
		SW	s2, -440(fp)
		SLT	s2, s4, s3
		SW	s2, -456(fp)
		SW	s3, -448(fp)
		LW	s2, -456(fp)
		BGTZ	s2, .L37
		J	.L38
.L37:
		LW	s3, -576(fp)
		LI	s4, 1
		SW	s2, -456(fp)
		SUB	s2, s3, s4
		SW	s2, -576(fp)
		SW	s3, -464(fp)
		LW	s3, -576(fp)
		LD	s4, -600(fp)
		MV	t2, s4
		LI	t3, 4
		MUL	t3, s3, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -496(fp)
		SW	s2, -472(fp)
		LD	t4, -496(fp)
		LW	s2, (t4)
		SW	s2, -592(fp)
		SD	s4, -488(fp)
		LW	s4, -592(fp)
		SW	s3, -480(fp)
		LI	s3, 91
		SW	s2, -504(fp)
		SUB	t6, s4, s3
		SEQZ	s2, t6
		SW	s2, -520(fp)
		SW	s4, -512(fp)
		LW	s2, -520(fp)
		BGTZ	s2, .L39
		J	.L40
.L38:
		SW	s2, -520(fp)
		J	.L34
.L39:
		LW	s2, -584(fp)
		LI	s3, 1
		SUB	s4, s2, s3
		SW	s4, -584(fp)
		SW	s2, -528(fp)
		SW	s4, -536(fp)
		J	.L41
.L40:
		LW	s2, -592(fp)
		LI	s3, 93
		SUB	t6, s2, s3
		SEQZ	s4, t6
		SW	s2, -544(fp)
		SW	s4, -552(fp)
		LW	s2, -552(fp)
		BGTZ	s2, .L42
		J	.L43
.L41:
		SW	s2, -552(fp)
		J	.L36
.L42:
		LW	s2, -584(fp)
		LI	s3, 1
		ADDW	s4, s2, s3
		SW	s4, -584(fp)
		SW	s2, -560(fp)
		SW	s4, -568(fp)
		J	.L43
.L43:
		J	.L41
.global main
main:
.L44:
		ADDI	sp, sp, -56
		SD	fp, 16(sp)
		ADDI	fp, sp, 56
		SD	ra, -48(fp)
		SD	s2, -56(fp)
.L45:
		ADDI	sp, sp, -16
		CALL	read_program
		ADDI	sp, sp, 16
		LA	t2, program
		ADD	t2, t2, zero
		SD	t2, -8(fp)
		ADDI	sp, sp, -16
		LD	a0, -8(fp)
		CALL	interpret
		ADDI	sp, sp, 16
		LI	t0, 0
		SW	t0, -32(fp)
		SD	a0, -8(fp)
		J	.L46
.L46:
		LW	s2, -32(fp)
		SW	s2, -24(fp)
		LW	a0, -24(fp)
		LD	s2, -56(fp)
		LD	ra, -48(fp)
		LD	fp, -40(fp)
		ADDI	sp, sp, 56
		RET

